package day24;

import java.io.*;
import java.util.Arrays;
import java.util.Comparator;

public class HomeWork {
}

class A3 {
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(isr);
        System.out.print("请输入一个字符串: ");
        String str = myNext(reader);
        System.out.println("你输入的字符串是: " + str);
        System.out.print("请输入一个整数: ");
        int num = myNextInt(reader);
        System.out.println("你输入的整数是: " + num);
    }
    static String myNext(BufferedReader reader) {
        try {
            String input = reader.readLine();
            return input.trim();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
    static int myNextInt(BufferedReader reader) {
        try {
            String input = reader.readLine();
            return Integer.parseInt(input.trim());
        } catch (IOException e) {
            e.printStackTrace();
            return 0;
        }
    }
}

class B3 {
    public static void main(String[] args) throws FileNotFoundException {
        File fis = new File("D:\\a");
        String[] a = fis.list();
        File[] b = fis.listFiles();
        String[] c = new String[a.length];
        String[] d = new String[a.length];
        //名称升序
        System.out.println("升序:");
        Arrays.sort(a);
        print(a);
        //名称降序
        System.out.println("降序:");
        Arrays.sort(a, Comparator.reverseOrder());
        print(a);
        //文件夹在前升序
        int n=0;
        int m=0;
        System.out.println("文件夹在前升序:");
        for(File f : b) {
            if(f.isDirectory()) {
                c[n] = f.getName();
                n++;
            }
            else {
                d[m] = f.getName();
                m++;
            }
        }
        print(c);
        print(d);
    }
    static void print(String[] s) {
        for(String ans : s) {
            if(ans==null) {continue;}
            System.out.println(ans);
        }
    }
}